package com.nyist.threadCase;

import com.nyist.thread.NyistThreadUtils;
import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.Callable;

/**
 * 1.
 *
 * @ClassName MyThreadRunnable
 * @Description
 * @Author xiaoyang
 * @Date 2023/04/03/20:19
 */
@Slf4j
public class MyThreadCallable implements Callable<Integer> {

    static volatile int ticket = 100;
    volatile int sum = 0;

    @Override
    public Integer call() throws Exception {
        // 线程执行的代码
        for (int i = 1; i <= ticket; i++) {
            sum++;
            log.info("=====>>>ThreadName:{} sum={}", NyistThreadUtils.getThreadName(), sum);
        }
        return sum;
    }
}